package com.shareware.common.utils

import android.content.Context
import android.content.SharedPreferences
import com.shareware.common.delegate.Preference
import com.shareware.common.getContextGlobal
import com.shareware.common.model.EnvironmentType

/**
 * desc: 功能描述
 * email: mobiledeveloper@qq.com
 */

const val PREFERENCE_SETTING = "preference.system"
private const val GLOBAL_HEADER = "global.header"
private const val APP_WINDOW_THEME = "app.window.theme"
private const val APP_ENVIRONMENT = "app.environment"
private const val APP_JENKINS_JOB = "app.jenkins"

var headers: String by Preference(GLOBAL_HEADER, "", PREFERENCE_SETTING)

var appTheme: Int by Preference(APP_WINDOW_THEME, 0, PREFERENCE_SETTING)

var appEnvironment: String by Preference(
    APP_ENVIRONMENT,
    EnvironmentType.PRODUCT.name, PREFERENCE_SETTING
)

var appJenkinsJob: Boolean by Preference(APP_JENKINS_JOB, false, PREFERENCE_SETTING)

fun clearPref(prefName: String) {
    getContextGlobal().getSharedPreferences(prefName, Context.MODE_PRIVATE).edit().clear().apply()
}

fun getPreferences(prefName: String): SharedPreferences {
    return getContextGlobal().getSharedPreferences(prefName, Context.MODE_PRIVATE)
}